<?php
session_start();
mysql_connect("127.0.0.1","root","sd2013");
mysql_select_db("mathRomp");
$urlCorrect = 'http://localhost/mathRomp/teacherHome.html';
$urlIncorrect = 'http://localhost/mathRomp/incorrectLogin.html';
$result = '';
$q=mysql_query("SELECT * FROM teachers WHERE username='".$_POST['username']."'");
while($e=mysql_fetch_assoc($q)){
  $output=$e;
}
$user = json_encode($output);
$user2 = json_decode($user);
if($user2->password == $_POST['password']){
  $_SESSION['teacherId'] = $user2->teacherId;
  header("Location: $urlCorrect");
}else{
  header("Location: $urlIncorrect");
}
mysql_close();